#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
MP4视频压缩工具 - 主程序入口
作者: AI助手
版本: 1.0.0
"""

import sys
import os
import tkinter as tk
from tkinter import messagebox

# 添加项目根目录到Python路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

def check_dependencies():
    """检查依赖是否安装"""
    try:
        import ffmpeg
        return True
    except ImportError:
        return False

def main():
    """主程序入口"""
    print("MP4视频压缩工具启动中...")
    print("版本: 1.0.0")

    # 检查依赖
    if not check_dependencies():
        print("错误: 缺少必要的依赖包")
        print("请运行: pip install -r requirements.txt")
        return

    try:
        # 启动GUI界面
        from gui.main_window import MainWindow

        app = MainWindow()
        app.run()

    except Exception as e:
        print(f"启动失败: {str(e)}")
        # 如果GUI启动失败，显示错误对话框
        try:
            root = tk.Tk()
            root.withdraw()  # 隐藏主窗口
            messagebox.showerror("启动错误", f"程序启动失败:\n{str(e)}")
        except:
            pass

if __name__ == "__main__":
    main()
